package 补充;
interface Sourceable{
    public void method();
}
class Source implements Sourceable{
    @Override
    public void method() {
        System.out.println("功能1");
    }
}
class Decorator implements Sourceable{
    private Sourceable sourceable;
    public Decorator(Sourceable sourceable){
        super();
        this.sourceable = sourceable;
    }
    @Override
    public void method() {
        sourceable.method();
        System.out.println("功能2");
        System.out.println("功能3");
    }
}
public class 装饰设计模式 {
    public static void main(String[] args) {
        Source source = new Source();
        System.out.println("-----------装饰前-------------");
        source.method();
        System.out.println("-----------装饰后-------------");
        Decorator decorator = new Decorator(source);
        decorator.method();
    }
}